784G - BF Calculator - CodeForces Solution


*special problem *2000

Please click on ads to support us..

Python Code:

def generate_bf_code(number):
    num_digits = int (len(str(number)))
    bf_code = ""
 
    if num_digits == 1:
        for i in range(number+48):
            bf_code += '+'
            
        bf_code += '.'
        print(bf_code)
        
    elif num_digits == 2:
        
        number1 = int(number/10)
        for i in range(number1+48):
            bf_code += '+'
            
        bf_code += ".>" 
        print(bf_code)
        bf_code = ""
        
        number2 = int(number%10)
        for i in range(number2+48):
            bf_code += '+'
            
        bf_code += '.'
        print(bf_code)
        
    else:
        number1 = int(number/100)
        for i in range(number1+48):
            bf_code += '+'
            
        bf_code += ".>" 
        print(bf_code)
        bf_code = ""
        
        number2 = int((number/10)%10)
        for i in range(number2+48):
            bf_code += '+'
            
        bf_code += '.>'
        print(bf_code)
        bf_code = ""
        
        number3 = int(number%10)
        for i in range(number3+48):
            bf_code += '+'
            
        bf_code += '.'
        print(bf_code)

expression = input()

result = int (eval(expression))
bf_code = generate_bf_code(result)

    

	  		  		 	 	  				  			   	


Comments

Submit
0 Comments
More Questions

1676E - Eating Queries
1447A - Add Candies
1721D - Maximum AND
363C - Fixing Typos
1401A - Distance and Axis
658A - Bear and Reverse Radewoosh
1721E - Prefix Function Queries
977E - Cyclic Components
1140D - Minimum Triangulation
75C - Modified GCD
1722A - Spell Check
1722B - Colourblindness
1722D - Line
1722C - Word Game
1722G - Even-Odd XOR
552E - Vanya and Brackets
933A - A Twisty Movement
1722F - L-shapes
1196B - Odd Sum Segments
1325D - Ehab the Xorcist
552B - Vanya and Books
1722E - Counting Rectangles
168A - Wizards and Demonstration
168B - Wizards and Minimal Spell
7A - Kalevitch and Chess
912B - New Year's Eve
1537C - Challenging Cliffs
879B - Table Tennis
1674E - Breaking the Wall
1282A - Temporarily unavailable